package hu.tetete.hibiscus;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import hu.tetete.hibiscus.taxontree.TaxonTreeActivity;
import hu.tetete.hibiscus.taxontree.TaxonTreeExpandableListActivity;

/**
 * The home page of the application.
 */
public class DashboardActivity extends Activity {

    /** Logging TAG. */
    @SuppressWarnings("unused")
    private static final String TAG = DashboardActivity.class.getName();

    /**
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.home);

        findViewById(R.id.taxonTreeMenuItem).setOnClickListener(new OpenTaxonTreeOnClickListener());
        findViewById(R.id.taxonSearchMenuItem).setOnClickListener(new OpenTaxonSearchOnClickListener());

    }

    private class OpenTaxonTreeOnClickListener implements View.OnClickListener {

        public OpenTaxonTreeOnClickListener() {
            /* NOP */
        }

        @Override
        public void onClick(final View v) {
            final Intent intent = new Intent(DashboardActivity.this, TaxonTreeActivity.class);
            startActivity(intent);
        }

    }

    private class OpenTaxonSearchOnClickListener implements View.OnClickListener {

        public OpenTaxonSearchOnClickListener() {
            /* NOP */
        }

        @Override
        public void onClick(final View v) {
            final Intent intent = new Intent(DashboardActivity.this, TaxonTreeExpandableListActivity.class);
            startActivity(intent);
        }

    }

    public static class HomeButtonListener implements View.OnClickListener {

        private final Context context;

        public HomeButtonListener(final Context context) {
            super();
            this.context = context;
        }

        public void onClick(final View v) {
            /* Navigate to the dashboard */
            final Intent newTaxonIntent = new Intent(context, DashboardActivity.class);
            context.startActivity(newTaxonIntent);
        }
    }

}
